<script lang="ts" setup>
import { injectState } from "../state";
import { jeecgbootSysPermissionDeleteBatch } from "@/genapi/wh-yqd";
defineOptions({ name: "Headler" });

const { selectedList,
        tableRef,
        detailDialogRef,
        detailDialogCopyRef,
        page: { records, isLoading, execute },
      } = injectState()!;
const deleteInBulk = async () => {
  console.log(selectedList.value)
  let ids = ''
  for(let i = 0; i < selectedList.value.length; i++){
    ids += selectedList.value[i].key+','
  }
  console.log(ids)
  await ElMessageBox.confirm(`确认删除吗？`, {
		type: "info",
		title: "提示",
	});
  let res = await jeecgbootSysPermissionDeleteBatch(ids)
  console.log(res)
	await execute();
  ElMessage.success(res.message);
}
</script>

<template>
	<div flex="~ justify-between">
		<div flex="~">
			<el-button
				@click="detailDialogRef?.trigger('create')"
				style="width: 80px"
				type="primary"
			>
				+ 新建
			</el-button>
			<el-button :disabled="selectedList.length === 0" style="width: 100px" @click="deleteInBulk()">
				批量删除
			</el-button>
		</div>
	</div>
</template>
